<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ImgUtil</title>
</head>
<body>
<input type="file" id="input">
<script src="../../../lib/baitu.min.js"></script>
<script>
    const {ImgUtil, FileUtil} = Baitu;
    const input = document.querySelector("#input");
    input.onchange = () => {
        const file = input.files[0];
        if (file) {
            try {
                FileUtil.toImage(file).then(res => {
                    console.log(res)
                    ImgUtil.toBlob(res.img).then(res => console.log(res)).catch(e => console.log(e))
                }).catch(e => console.log(e))
                // ImgUtil.cut(file, 300, 300, 500, 700, 0.5).then(res => {
                //     console.log(res)
                //     Baitu.FileUtil.downloadBlob(res.blob, res.name);
                // })
                // ImgUtil.resize(file, 300, 300).then(res => {
                //     console.log(res)
                //     Baitu.FileUtil.downloadBlob(res.blob, res.name);
                // })
            } catch (error) {
                console.error('Error reading file:', error);
            }
        }
    };
</script>
</body>
</html>
